<!DOCTYPE html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Hello, Bootstrap Table!</title>
    <link rel="stylesheet" href="https://kit-free.fontawesome.com/releases/latest/css/free.min.css">
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
          integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
    <link rel="stylesheet" href="https://unpkg.com/bootstrap-table@1.15.4/dist/bootstrap-table.min.css">
    <link href="https://cdn.jsdelivr.net/gh/Talv/x-editable@develop/dist/bootstrap4-editable/css/bootstrap-editable.css"
          rel="stylesheet">
    <link href="/web/libs/bootstrap/4.0/css/bootstrap-table-fixed-columns.min.css" rel="stylesheet">
    <link href="/web/libs/bootstrap/4.0/css/dashboard.css" rel="stylesheet">

    <script src="https://code.jquery.com/jquery-3.3.1.min.js"
            integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
    <!--<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>-->
    <script src="/web/libs/js/popper.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"
            integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k"
            crossorigin="anonymous"></script>
    <script src="https://unpkg.com/bootstrap-table@1.15.4/dist/bootstrap-table.min.js"></script>
    <script src="https://unpkg.com/bootstrap-table@1.15.4/dist/extensions/editable/bootstrap-table-editable.min.js"></script>
    <script src="https://cdn.jsdelivr.net/gh/Talv/x-editable@develop/dist/bootstrap4-editable/js/bootstrap-editable.min.js"></script>
    <script src="/web/libs/js/bootstrap-table-fixed-columns.min.js"></script>
</head>

<body>
<div id="header"></div>
<div class="container-fluid">
    <div class="row">
        <div id="menu"></div>
        <main class="col-sm-9 offset-sm-3 col-md-10 offset-md-2 pt-3">
            <div class="container">
                <div class="input-group">
                    股票代码:<input type="text" class="form-control" id="code" value="">
                    所属行业:<input type="text" class="form-control" id="hyname" value="">
                    <span lass="input-group-btn"> <button class="btn btn-default" type="button" id="orderShareSZ"
                                                          value="ShareSZ">市值排序</button> </span>
                    <span lass="input-group-btn"> <button class="btn btn-default" type="button" id="orderLTZB"
                                                          value="LTZB">占流通股比</button> </span>
                    <span lass="input-group-btn"> <button class="btn btn-default" type="button" id="orderZZB"
                                                          value="ZZB">占总股本比</button> </span>

                    <span lass="input-group-btn"> <button class="btn btn-default" type="button"
                                                          id="orderSource">总排名来源</button> </span>
                </div>


                <div id="rptList" style="width: 100%; hight: 100%; float: left;">
                    <table class="table table-hover" id="cusTable">
                    </table>
                </div>
        </main>
    </div>
</div>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!--<script src="/web/libs/js/jquery-3.1.1.slim.min.js"-->
<!--        integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n"-->
<!--        crossorigin="anonymous"></script>-->
<!--<script src="/web/libs/js/tether.min.js"-->
<!--        integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb"-->
<!--        crossorigin="anonymous"></script>-->
<!--<script src="/web/libs/bootstrap/4.0/js/bootstrap.min.js"></script>-->
<script src="/web/libs/js/common.js"></script>
<script src="/web/libs/js/jquery.js"></script>
<script src="/web/libs/js/dashboard/index.js"></script>
<!--<script src="/web/libs/bootstrap/4.0/js/bootstrap-table.js"></script>-->
<script src="https://unpkg.com/bootstrap-table@1.15.4/dist/bootstrap-table.min.js"></script>
<script src="/web/libs/js/dashboard/basedata.js"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
        integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js" integrity="sha384-wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut" crossorigin="anonymous"></script>-->
<script src="/web/libs/js/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"
        integrity="sha384-B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k"
        crossorigin="anonymous"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.4/dist/bootstrap-table.min.js"></script>
<script src="https://unpkg.com/bootstrap-table@1.15.4/dist/extensions/editable/bootstrap-table-editable.min.js"></script>

<script src="https://cdn.jsdelivr.net/gh/Talv/x-editable@develop/dist/bootstrap4-editable/js/bootstrap-editable.min.js"></script>


<script src="/web/libs/js/bootstrap-table-fixed-columns.min.js"></script>

<script type="text/javascript">
    $("#header").load("/web/header.html")
    addActive("m_eastHstgcg");
    // $('#cusTable').bootstrapTable('destroy');
    $('#queryDate').val(new Date().format("yyyyMMdd"));
    $('#endDate').val(new Date().format("yyyyMMdd"));
    var orderValue = "ShareSZ";

    function loadData(orderValue) {
        $('#cusTable').bootstrapTable('destroy');
        $("#cusTable").bootstrapTable(
            {
                method: "get", //使用get请求到服务器获取数据
                url: "/web/eastHsgtcg/query", //获取数据的Servlet地址
                striped: true, //表格显示条纹
                pagination: true, //启动分页
                cache: false,
                pageNumber: 2, //当前第几页
                search: false, //是否启用查询
                sortable: true,                     //是否启用排序
                //sortOrder: "asc",                   //排序方式
                //showColumns: true,  //显示下拉框勾选要显示的列
                //showRefresh: true,  //显示刷新按钮
                //sidePagination: "server", //表示服务端请求
                //设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
                //设置为limit可以获取limit, offset, search, sort, order
                //queryParamsType: "undefined",
                pageSize: 10, //每页显示的记录数
                //pageNumber:1, //当前第几页
                pageList: [3, 5, 10, 15], //记录数可选列表
                queryParams: function queryParams(params) { //设置查询参数
                    var queryDate = $('#queryDate').val();
                    var hyname = $('#hyname').val();
                    var code = $('#code').val();


                    var param = {
                        pageNum: params.pageNumber,
                        pageSize: params.pageSize,
                        sortName: orderValue,      //排序列名
                        sortOrder: params.sortOrder //排位命令（desc，asc）
                    };
                    param.queryDate = queryDate;
                    param.code = code;
                    param.hyname = hyname;
                    return param;
                },
                columns: [{
                    field: 'code',
                    title: '股票代码',
                    formatter: function (value, row, index) {
                        return '<a href="javascript:open(\'http://data.eastmoney.com/hsgtcg/StockHdStatistics.aspx?stock=' + row.code + '\',\'' + row.code + '\')">' + value + '</a>';
                    }
                }, {
                    field: 'name',
                    title: '股票名称',
                    formatter: function (value, row, index) {
                        return '<a href="javascript:open(\'http://basic.10jqka.com.cn/' + row.code + '\',\'' + row.code + '\')">' + value + '</a>';
                    }
                }, {
                    field: 'gsld',
                    title: '公司亮点',
                }, {
                    field: 'newPrice',
                    title: '今日收盘价',
                    sortable: true,
                }, {
                    field: 'guzhi',
                    title: '估价',
                    editable: true,
                    sortable: true,
                }, {
                    field: 'mark',
                    title: '操作日志备注',
                    editable: true,
                    sortable: true,
                }, {
                    field: 'hyname',
                    title: '所属行业',
                }, {
                    field: 'shareSZ',
                    title: '市值',
                }, {
                    field: 'ltzb',
                    title: '占流通股比',
                }, {
                    field: 'zzb',
                    title: '占总股本比',
                }, {
                    field: 'dqname',
                    title: '所属板块',
                }, {
                    field: 'zdf',
                    title: '今日涨跌幅',
                }, {
                    field: 'shareHold',
                    title: '股数',
                }, {
                    field: 'shareHold_Chg_One',
                    title: '增持股数',
                }, {
                    field: 'shareSZ_Chg_One',
                    title: '增持市值',
                }, {
                    field: 'shareSZ_Chg_Rate_One',
                    title: '增持市值增幅',
                }, {
                    field: 'ltzb_One',
                    title: '增持占流通股比',
                }, {
                    field: 'zzb_One',
                    title: '增持占总股本比',
                    editable: true,
                }, {
                    field: 'operate',
                    title: '估值/操作',
                    align: 'center',
                    events: "operateEvents",
                    formatter: operateFormatter
                }],
                fixedColumns: true,
                fixedNumber: +3,
                fixedRightNumber: +1,
                responseHandler: function responseHandler(res) {

                    var s1 = JSON.stringify(res.result);
                    var s2 = '{"total":9999,"rows":' + s1 + '}';
                    //alert(s2);
                    return eval('(' + s2 + ')')
                },
                onLoadSuccess: function () { //加载成功时执行
                    $("#rptList").show();
                },
                onLoadError: function () { //加载失败时执行
                    alert("加载数据失败");
                },
                onEditableSave: function (field, row, oldValue, $el) {
                    $.ajax({
                        type: "post",
                        url: "/web/eastHsgtcg/edit",
                        data: row,
                        dataType: 'JSON',
                        success: function (data, status) {
                            if (status == "success") {
                                alert('提交数据成功');
                            }
                        },
                        error: function () {
                            alert('编辑失败');
                        },
                        complete: function () {

                        }

                    });
                }
            });
    }

    function operateFormatter(value, row, index) {
        return [
            '<button type="button" class="btnGUZHI btn btn-default  btn-sm">估值</button>'
        ].join('');
    }

    window.operateEvents = {
        'click .RoleOfD': function (e, value, row, index) {
            alert(row.code + "|" + row.UserName);
        },
        'click .btnGUZHI': function (e, value, row, index) {
            exportGUZHI(row.code, row.name);
        }
    };

    $("#orderShareSZ").click(function () {
        var orderValue = $('#orderShareSZ').val();
        loadData(orderValue)
    });

    $("#orderLTZB").click(function () {
        var orderValue = $('#orderLTZB').val();
        loadData(orderValue)
    });

    $("#orderZZB").click(function () {
        var orderValue = $('#orderZZB').val();
        loadData(orderValue)
    });
    $("#orderSource").click(function () {
        window.open("http://data.eastmoney.com/hsgtcg/list.html");
    });

    // $("#downAction").click(function () {
    function exportGUZHI(code, name) {
        window.location.href = "/web/eastHsgtcg/downloadGuZhi?code=" + code + "&name=" + name;
    };
    loadData("LTZB");
</script>
</body>
</html>
